from fastapi import APIRouter
from langchain_community.chat_models.google_palm import chat_with_retry
from openai.resources import AsyncChatWithRawResponse

from core.agent_core import agent_chat
from entity.schema.rag_schema import RagInput
from utils.base_response import BaseResponse

agent = APIRouter()

@agent.post("/chat")
async def chat(input: RagInput):
    result = await agent_chat(input.api_key, input.user_input)
    return BaseResponse(code=200, msg="success", data=result)